package library.gui.component;

import javafx.scene.control.Button;

public class FunctionalButton extends Button{
	
	private Runnable finalRunnable = null;
	
	public FunctionalButton(String text) {
		super(text);
	}
	
	public FunctionalButton(String text, Runnable runnable) {
		super(text);
		setFunction(runnable);
	}
	
	public void setFunction(Runnable runnable) {
		this.setOnAction((x)->{
			runnable.run();
			if(finalRunnable != null) finalRunnable.run();
		});
	}
	
	public void setFinal(Runnable f) {
		this.finalRunnable = f;
	}
	
}
